#include "StdAfx.h"
#include "SphereEditor.h"
#include "EditorHelper.h"
#include "./FunctionDrivers/FunctionDriverSphere.h"

REGISTERE_EDITOR(CSphereEditor);

CSphereEditor::CSphereEditor(void)
{
	
}

CSphereEditor::~CSphereEditor(void)
{

}
CString CSphereEditor::GetID(void)
{
	return SPHERE_CR_GUID;
}

CSphereInfo* CSphereEditor::GetShapeInfo()
{
	return &m_Info;
}

void CSphereEditor::Initialize(CAnyView* pView)
{
	m_Info.Reset();

	AddSubEditor(new CPointCapture(m_Info.ptCenter), 
		CSphereInfo::CENTER_POINT);
	AddSubEditor(new CLengthCapture(m_Info.ptCenter, m_ptEnd, m_Info.dRadius),
		CSphereInfo::RADIUS);

	CModelEditor::Initialize(pView);
}


bool CSphereEditor::CreatePreviewShape()
{
	if(CurrentStep() == CSphereInfo::CENTER_POINT)
		return false;

	TopoDS_Shape shape;
	CSphereBuilder builder;
	if(builder.Build(&m_Info, shape))
	{
		SetPreviewShape(shape);
		return true;
	}
	
	return false;

}

bool CSphereEditor::CreateShapeLabel(TDF_Label& label)
{
	label = NewLabel(_T("Sphere"));;

	m_Info.AddToLabel(label);

	Handle(CFunctionDriverSphere) functionDriver;
	return ProcessFunctionDriver<CFunctionDriverSphere>(label, functionDriver);
}